<template>
  <div class="ec-app-container">
    <!-- 查询条件 -->
    <div class="filter-container">
      <el-form label-width="90px">
        <el-row :gutter="10">
          <el-col :span="6">
            <el-form-item label="标题：" >
              <el-input v-model="listQuery.title" placeholder="姓名"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="资讯类型：">
              <el-select v-model="listQuery.informationType" placeholder="资讯类型" clearable>
                <el-option v-for="(item, index) in informationTypes" :key = "index" :label= "item.object.name" :value="item.id"/>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="发布状态：">
              <el-select v-model="listQuery.status" placeholder="发布状态" style="width: 100%;" clearable >
                <el-option v-for="(item, index) in GLOBAL.status" :key="index" :label="item" :value="index"/>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6" class="text-center">
            <el-button type="primary" class="border-4C7FD7 color-4C7FD7" icon="el-icon-search" @click="searchList">查询</el-button>
            <el-button class="border-4C7FD7 color-4C7FD7" @click="resetSearch">重置</el-button>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <!-- table -->
    <div>
      <div class="mt-30">
        <!--<el-button class="filter-item" type="primary" @click="searchList">待发布</el-button>-->
        <!--<el-button class="filter-item" type="primary" @click="searchList"></el-button>-->
        <el-button class="filter-item" type="primary" @click="searchList">批量下架</el-button>
        <el-button class="filter-item" type="primary" @click="toPath('createnews')">新增</el-button>
      </div>
      <div class="mt-20">
        <el-table
          v-loading="listLoading"
          :data="list"
          border
          fit
          highlight-current-row
          style="width: 100%;"
          @selection-change="handleSelectionChange"
        >
          <el-table-column
            type="selection"
            width="55"/>
          <el-table-column label="操作" align="center" width="230" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <el-button v-if="scope.row.object.status === 1" type="text" size="mini" @click="releaseStatus(scope.row, 0, '发布资讯')">发布</el-button>
              <el-button v-else type="text" size="mini" @click="releaseStatus(scope.row, 1, '撤销资讯')">撤销</el-button>
              <el-button type="text" size="mini" @click="toPath('createnews/'+scope.row.id)">编辑</el-button>
              <el-button type="text" size="mini" @click="deleteDate(scope.row.id, '删除资讯')">删除</el-button>
            </template>
          </el-table-column>
          <el-table-column label="标题" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.object.title }}</span>
            </template>
          </el-table-column>
          <el-table-column label="资讯类型" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.object.informationType }}</span>
            </template>
          </el-table-column>
          <el-table-column label="状态" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.object.status | releaseStatus }}</span>
            </template>
          </el-table-column>
          <el-table-column label="发布时间" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.object.releaseTime }}</span>
            </template>
          </el-table-column>
          <el-table-column label="责任编辑" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.object.editorCharge }}</span>
            </template>
          </el-table-column>
          <el-table-column label="操作人" align="center">
            <template slot-scope="scope">
              <span>暂时没有</span>
            </template>
          </el-table-column>
          <el-table-column label="操作时间" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.updateTime }}</span>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <pagination v-show="total>0" :total="total" :page.sync="listQuery.pageNum" :limit.sync="listQuery.pageSize" @pagination="searchList" />
    </div>
  </div>
</template>

<script>
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination、
export default {
  name: 'News',
  components: {
    Pagination
  },
  data() {
    return {
      informationTypes: [],
      listQuery: {
        level: 'fy_newsDissemination',
        title: '',
        informationType: '',
        status: '',
        pageSize: 10,
        pageNum: 1
      }
    }
  },
  created() {
    // 初始化
    this.searchList()
    // 初始化分类内容
    let query = {
      level: 'informationClassification',
      pageSize: 10,
      pageNum: 1
    }
    query = this.setListQuery(query)
    this.searchListAll(query).then((res) => {
      this.informationTypes = res.data.list
    })
  },
  methods: {

  }
}
</script>

<style scoped>

</style>
